import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return VueRouterPush.call(this, location).catch(error=> error)
}

const routes = [
  {
    path: '/',
    redirect: '/elephant'
  },
  {
    path: '/elephant',
    name: 'elephant',
    component: () => import('@views/elephant/elephant.vue'),
    meta: {
      key: 'elephant'
    }
  },
  {
    path: '/404',
    name: 'Without',
    component: () => import('@views/error/404.vue')
  },
  {
    path: '*',
    redirect: '/404'
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})


export default router
